package br.com.webcrm.view;

import java.util.List;

import br.com.webcrm.model.QuestAlternativa;

@SuppressWarnings("serial")
public class QuestAlternativaDataModel extends PrimeDataModel<QuestAlternativa> {

	public QuestAlternativaDataModel() {
	}

	public QuestAlternativaDataModel(Object data) {
		super(data);
	}

	@SuppressWarnings("unchecked")
	@Override
    public QuestAlternativa getRowData(String rowKey) {
        //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data
        
        List<QuestAlternativa> alternativas = (List<QuestAlternativa>) getWrappedData();
        
        for(QuestAlternativa alternativa : alternativas) {
        	String id = ""+alternativa.getIdAlternativa();
            if(id.equals(rowKey))
                return alternativa;
        }
        
        return null;
    }

    @Override
    public String getRowKey(QuestAlternativa alternativa) {
        return ""+alternativa.getIdAlternativa();
    }
}
